#     Xepec.ru - социальная сеть
#     Copyright (C) 2008  Fedorchenko Alexander
#
#     This program is free software: you can redistribute it and/or modify
#     it under the terms of the GNU Affero General Public License as
#     published by the Free Software Foundation, either version 3 of the
#     License, or (at your option) any later version.
#
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU Affero General Public License for more details.
#
#     You should have received a copy of the GNU Affero General Public License
#     along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#     Autor: Fedorchenko Alexander
#     Mail: sos20@list.ru
#     Date: 17/01/2009
#
#
#TODO: Бороться с HTML на перле так же как на PHP #$stat = htmlentities($stat, ENT_NOQUOTES, "UTF-8");
require "../core.pl";

sub change_status
{
	use CGI::Cookie;
	require "../config.pl";
	
	my %cookies = fetch CGI::Cookie;
	my $nic_cook = $cookies{'xepec_nic'}->value;
	my $pass_cook = $cookies{'xepec_pass'}->value;
		
	my $ath = $dbcnx->do(qq{UPDATE username SET status='$_[0]' WHERE id IN(SELECT id FROM reg WHERE name='$nic_cook' and md5='$pass_cook')});
	$dbcnx->disconnect();
	if ($ath == 1)
	{
		#return 1;
		print $_[0];
	}
	else
	{
		#return 0;
		print "У нас временные проблемы";
	}
}
#print "Content-type: text/plain; charset=utf-8\n\n";
print "Content-Type: text/html; charset=utf-8\n\n";

&get_query();
$stat=$queryString{ "status" };
#$stat="lllllss";
#$stat = htmlentities($stat, ENT_NOQUOTES, "UTF-8");
$stat =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;


change_status($stat);

#if (change_status($stat))
#{
#	print $stat;
#}
#else
#{
#	print "У нас временные проблемы";
#}
